package com.qin.EducationalManger.course.service.Imp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.qin.EducationalManger.course.dao.CourseDao;
import com.qin.EducationalManger.course.model.CourseModel;
import com.qin.EducationalManger.course.model.StudentCourseModel;
import com.qin.EducationalManger.course.model.namesModel;
import com.qin.EducationalManger.course.service.CourseService;
import com.qin.EducationalManger.student.dao.StudentDao;
import com.qin.EducationalManger.student.model.StudentModel;

public class CourseServiceImp implements CourseService{

	@Override
	public Integer insert(CourseModel model) {
		// TODO Auto-generated method stub
		return CourseDao.insert(model);
	}

	
	public Integer delete(CourseModel model) {
		
		
		
		return CourseDao.delet(model);
		// TODO Auto-generated method stub
	
	}

	@Override
	public Integer update(CourseModel model) {
		// TODO Auto-generated method stub
		return CourseDao.update(model);
	}

	@Override
	public List<CourseModel> select(CourseModel model) {
		String courseId = model.getCourseId();
		String courseName = model.getCourseName();
        //模糊查找
		model.setCourseName(courseName==null?"%%":"%"+courseName+"%");
		// TODO Auto-generated method stub
		
		
		
		
		return CourseDao.select(model);
	}
	public List<namesModel> selectCourse(CourseModel model) {
		// TODO Auto-generated method stub
		List<CourseModel> models = CourseDao.select(model);
	    
		List<namesModel> names = new ArrayList<namesModel>();
          		
		for(int i =0;i<models.size();i++) {
			namesModel namesModel = new namesModel();
			String courseId =models.get(i).getCourseId();
			String courseName = models.get(i).getCourseName();
			namesModel.setCourseId(courseId);
			namesModel.setCourseName(courseName);
			names.add(namesModel);
		
		}

		return names;
	}
	
	
	public List<StudentCourseModel> select(String [] courseIds) {

	
		return CourseDao.select(courseIds);
		
		
}
	public Integer selectCount(CourseModel model) {
		// TODO Auto-generated method stub
		return CourseDao.selectCount(model);
	
	}


}
